cd "C:\Users\..."

* TABLE 1 OLS regressions estimating the relationship between treatment and anti-refugee voting behavior in the 2016 Hungarian Quota Referendum.
* Note: stanrdard errors may change due to bootstrap sampling
insheet using settlements_ols.csv, delimiter(";") clear
* Model (1)
reg ref_no_votes_over_eligible treatment fidesz_share_2014 jobbik_share_2014 pc_income pct_unemployed pct_higher_ed log_ref_eligible_voters, vce(bootstrap)
est store model1

* Model (2) with Year FE
reg ref_no_votes_over_eligible treatment fidesz_share_2014 jobbik_share_2014 pc_income pct_unemployed pct_higher_ed log_ref_eligible_voters  within_25km_of_border ///
i.county_id, vce(bootstrap)
est store model2

* Model (3) Minutes to Treatment
reg ref_no_votes_over_eligible treatment min_to_treatment fidesz_share_2014 jobbik_share_2014 pc_income pct_unemployed pct_higher_ed log_ref_eligible_voters, vce(bootstrap)
est store model3

* Model (4) Minutes to Treatment binned 
reg ref_no_votes_over_eligible  ///
i.bin  ///
fidesz_share_2014 jobbik_share_2014 log_ref_eligible_voters pc_income pct_unemployed pct_higher_ed  ///
,vce (bootstrap)
est store model4

* Displays regression table
esttab model1 model2 model3 model4 /// 
using TABLE1, order(treatment min_to_treatment) replace se(3) ar2 obslast nobaselevels  drop(pc_income pct_unemployed pct_higher_ed)  indicate(*county*) star(* 0.10 ** 0.05 *** 0.01) nonumbers


// ssc install diff
// diff package is required to run DID estimations
* TABLE 2 Difference-in-differences estimation results and placebo tests.
insheet using settlements_did.csv, delimiter(";") clear
* Change in Fidesz vote share 2014-2018
diff fidesz, t(t) p(time)  kernel id(v1) cov( pc_income pct_at_least_hs pct_unemployed  km_to_any_border)

* Change in Jobbik vote share 2014-2018
diff jobbik, t(t) p(time)  kernel id(v1) cov( pc_income pct_at_least_hs pct_unemployed  km_to_any_border)

* Change in Right-wing vote share 2014-2018
diff right, t(t) p(time)  kernel id(v1) cov(pc_income pct_at_least_hs pct_unemployed  km_to_any_border)

insheet using settlements_did_placebo.csv, delimiter(";") clear
* Change in Fidesz vote share 2010-2014 (Placebo treatment)
diff fidesz_placebo , t(t) p(time)  kernel id(v1) cov(pc_income pct_at_least_hs pct_unemployed  km_to_any_border)

* Change in Jobbik vote share 2010-2014 (Placebo treatment)
diff jobbik_placebo, t(t) p(time)  kernel id(v1) cov(pc_income pct_at_least_hs pct_unemployed  km_to_any_border)

* Change in Right-wing vote share 2010-2014 (Placebo treatment)
diff right_placebo, t(t) p(time)  kernel id(v1) cov(pc_income pct_at_least_hs pct_unemployed  km_to_any_border)




